package com.hj.security.handler;


import com.hj.security.domain.resp.SecurityResp;
import com.hj.security.utils.ResponseUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;


/**
 * @author hj
 * @Date 2023/4/26
 * @Description: AccessDeniedHandler
 */
@Component
public class HjAccessDeniedHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) {
        SecurityResp resp = new SecurityResp();
        resp.setCode(403);
        resp.setMsg("没有访问权限");
        ResponseUtil.responseJson(response, resp);
    }


}
